﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using EnvironmentManagerSystem.BLL;
using EnvironmentManagerSystem.MODE;
using EnvironmentManagerSystem.Utility;

namespace EnvironmentManagerSystem.HuanJing
{
    public partial class Systemconfig : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (StfInfo.ReSession()) return; if (!IsPostBack)
            {
                Bind();
                if (!Convert.ToBoolean(Session["Admin"]))
                {
                    btn_Open.Enabled = false;
                    btn_Close.Enabled = false;
                }
                else 
                {
                    btn_Open.Enabled = true;
                    btn_Close.Enabled = true;
                }
                
            }
        }

        private void Bind() 
        {
            DataTable dt = SystemconfigService.GetSystemconfigSEL();
            if (dt.Rows.Count == 0)
                return;
            string SmsOpened =dt.Rows[0]["SmsOpened"].ToString().Trim();
            if (SmsOpened == "1")
            {
                Label1.Text = "短信已启用！";
                btn_Open.Visible = false;
                btn_Close.Visible = true;
            }
            else
            {
                Label1.Text = "短信未启用！";
                btn_Open.Visible = true;
                btn_Close.Visible = false;
            }
        }

        #region Button_Click
        //短信启用
        protected void btn_Open_Click(object sender, EventArgs e)
        {
            int SmsOpened = 1;//是否开启短信功能(默认是1开启)
            if (SystemconfigService.UdEnabled(SmsOpened) == true)
                Jscript.Alert("短信启用成功!", this);
            else
                Jscript.Alert("短信启用失败!", this);
        }
        //短信关闭
        protected void btn_Close_Click(object sender, EventArgs e)
        {
            int SmsOpened = 0;//是否开启短信功能(默认是1开启)
            if (SystemconfigService.UdEnabled(SmsOpened) == true)
                Jscript.Alert("短信关闭成功!", this);
            else
                Jscript.Alert("短信关闭失败!", this);
        }
        #endregion
    }
}
